﻿@using Hetang.Models.ControlExtensions
@model Hetang.Areas.User.Models.Classes.dt_Resume
@{
    ViewBag.Title = "求职管理中心";
    ViewBag.SettingTitle = Model == null ? "创建个人求职基本信息" : "修改个人求职基本信息";
    Layout = "~/Views/Shared/_UserLayout.cshtml";
    ViewBag.Required = true;
}

<div class="bs-docs-grid">
    @if (Model == null)
    {
        <div class="alert fade in" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>提示!</strong> 你还没有创建你的简历信息，马上填写简历信息让企业更加了解你！
        </div>
    }
    @if (TempData["Info"] != null)
    {
        <div class="alert alert-success fade in auto-hidden" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>@TempData["Info"]</strong>
        </div>
    }
    @if (TempData["Error"] != null)
    {
        <div class="alert alert-error fade in" style="width:750px;">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <strong>@TempData["Error"]</strong>
        </div>
    }
    <div class="row show-grid">
        <div class="span12">
            @using (Html.BeginForm("index", "person", FormMethod.Post, new { @class = "form-horizontal" }))
            {
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Name, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.Name, new { maxlength = 10 })
                        @Html.ValidationMessageFor(model => model.resume.Name)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Sex, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Sex, "先生", new { @checked = "checked" })先生</label>
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Sex, "小姐")小姐</label>
                        @Html.ValidationMessageFor(model => model.resume.Sex)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Domicile, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @{
                Hetang.Areas.User.Models.Classes.dt_Resume_Domicile domicile = new Hetang.Areas.User.Models.Classes.dt_Resume_Domicile() { city = "江门", town = "荷塘" };
                if (Model != null)
                {
                    if (!string.IsNullOrEmpty(Model.resume.Domicile))
                    {
                        domicile = Hetang.Models.Helper.JsonHelper.parse<Hetang.Areas.User.Models.Classes.dt_Resume_Domicile>(Model.resume.Domicile);
                    }
                }

                Hetang.Models.Interface.IConfigRepository _cr = new Hetang.Models.Repository.ConfigRepository();
                List<Hetang.Areas.User.Models.Classes.dt_Domicile_City> dt_city = _cr.GetResumeDomicile();
                List<SelectListItem> city = new List<SelectListItem>();
                List<SelectListItem> town = new List<SelectListItem>();

                foreach (var c in dt_city)
                {
                    if (c.name.Equals(domicile.city))
                    {
                        city.Add(new SelectListItem { Text = c.name, Value = c.name, Selected = true });

                        foreach (var t in c.townList)
                        {
                            if (t.name.Equals(domicile.town))
                            {
                                town.Add(new SelectListItem { Text = t.name, Value = t.name, Selected = true });
                            }
                            else
                            {
                                town.Add(new SelectListItem { Text = t.name, Value = t.name });
                            }
                        }
                    }
                    else
                    {
                        city.Add(new SelectListItem { Text = c.name, Value = c.name });
                    }
                }
                        }
                        @Html.DropDownListFor(model => model.city, city, new { @class="dropdownfix" })
                        @Html.DropDownListFor(model => model.town, town, new { @class="dropdownfix" })
                        @Html.ValidationMessageFor(model => model.city)
                        @Html.ValidationMessageFor(model => model.town)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Born, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @{
                List<SelectListItem> year = new List<SelectListItem>();
                List<SelectListItem> month = new List<SelectListItem>();
                List<SelectListItem> day = new List<SelectListItem>();

                int y = Model != null ? string.IsNullOrEmpty(Model.resume.Born.Year.ToString()) ? 1980 : Model.resume.Born.Year : 1980;
                int m = Model != null ? string.IsNullOrEmpty(Model.resume.Born.Month.ToString()) ? 1 : Model.resume.Born.Month : 1;
                int d = Model != null ? string.IsNullOrEmpty(Model.resume.Born.Day.ToString()) ? 1 : Model.resume.Born.Day : 1;

                for (int i = 1980; i <= DateTime.Now.Year - 18; i++)
                {
                    if (i == y)
                    {
                        year.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i), Selected = true });
                    }
                    else
                    {
                        year.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i) });
                    }
                }

                for (int i = 1; i <= 12; i++)
                {
                    if (i == m)
                    {
                        month.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i), Selected = true });
                    }
                    else
                    {
                        month.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i) });
                    }
                }

                int[] d1 = { 1, 3, 5, 7, 8, 10, 12 }; //31日的月份
                int[] d2 = { 4, 6, 9, 11 }; // 30日的月分
                int d3 = 0;

                if (d1.Contains(m))
                {
                    d3 = 31;
                }
                else if (d2.Contains(m))
                {
                    d3 = 30;
                }
                else if (DateTime.IsLeapYear(y))
                {
                    d3 = 29;//润年二月份29日
                }
                else
                {
                    d3 = 28;
                }


                for (int i = 1; i <= d3; i++)
                {
                    if (i == d)
                    {
                        day.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i), Selected = true });
                    }
                    else
                    {
                        day.Add(new SelectListItem { Text = Convert.ToString(i), Value = Convert.ToString(i) });
                    }
                }
                        }

                        @Html.DropDownListFor(model => model.BornYear, year, new { @class="dropdownfix" })
                        @Html.DropDownListFor(model => model.BornMonth, month, new { @class="dropdownfix" })
                        @Html.DropDownListFor(model => model.BornDay, day, new { @class="dropdownfix" })
                        @Html.ValidationMessageFor(model => model.BornYear)
                        @Html.ValidationMessageFor(model => model.BornMonth)
                        @Html.ValidationMessageFor(model => model.BornDay)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.School, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.School, new { @maxlength = 20 })
                        @Html.ValidationMessageFor(model => model.resume.School)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Profession, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.Profession, new { @maxlength = 20 })
                        @Html.ValidationMessageFor(model => model.resume.Profession)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Learn, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @{
                List<SelectListItem> edu = new List<SelectListItem>(){
                        new SelectListItem{Text="小学",Value="小学"},
                        new SelectListItem{Text="初中",Value="初中"},
                        new SelectListItem{Text="高中",Value="高中"},
                        new SelectListItem{Text="中专",Value="中专"},
                        new SelectListItem{Text="大专",Value="大专"},
                        new SelectListItem{Text="本科",Value="本科"},
                        new SelectListItem{Text="硕士",Value="硕士"},
                        new SelectListItem{Text="博士",Value="博士"}
                    };
                        }
                        @Html.DropDownListFor(model => model.resume.Learn, edu, new { @class="dropdownfix", @important = "*" })
                        @Html.ValidationMessageFor(model => model.resume.Learn)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Computer, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Computer, "不懂", new { @checked = "checked" })不懂</label>
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Computer, "一般")一般</label>
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Computer, "良好")良好</label>
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Computer, "熟练")熟练</label>
                        <label class="radio inline">@Html.RadioButtonFor(model => model.resume.Computer, "精通")精通</label>
                        @Html.ValidationMessageFor(model => model.resume.Computer)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.English, new { @class = "control-label" })
                    <div class="controls">
                        <ul class="english-list">
                            @{
                List<SelectListItem> english = _cr.GetPersonEnglistList();
                
                for (int i = 0; i < english.Count(); i++)
                {
                    var ischecked = "";
                    if (Model != null)
                    {
                        if (!string.IsNullOrEmpty(Model.resume.English))
                        {
                            if (Model.resume.English.Contains(english[i].Value))
                            {
                                ischecked = "checked='checked'";
                            }
                        }
                    }
                                <li class="pull-left">
                                    <label class="checkbox inline">
                                        <input type="checkbox" name="EnglishList" value ="@english[i].Value" @ischecked />
                                        @english[i].Value</label></li>
                }
                            }

                        </ul>
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Phone, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.Phone, new { @maxlength = 13 })
                        @Html.ValidationMessageFor(model => model.resume.Phone)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.QQ, new { @class = "control-label" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.QQ, new { @maxlength = 11 })
                        @Html.ValidationMessageFor(model => model.resume.QQ)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.WebSite, new { @class = "control-label" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.WebSite, new { @class = "span10" , @maxlength = 50 })
                        @Html.ValidationMessageFor(model => model.resume.WebSite)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Address, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextBoxFor(model => model.resume.Address, new { @class = "span10" })
                        @Html.ValidationMessageFor(model => model.resume.Address)
                    </div>
                </div>
                
                <div class="control-group">
                    @Html.LabelFor(model => model.resume.Letter, new { @class = "control-label", @important = "*" })
                    <div class="controls">
                        @Html.TextAreaFor(model => model.resume.Letter, new { @class="span10" })
                        @Html.ValidationMessageFor(model => model.resume.Letter)
                    </div>
                </div>
                
                <div class="control-group">
                    <div class="controls">
                        <button type="submit" class="cbtn cbtn-info cbtn-large">保存</button>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@Html.GetJavascript("jquery.validate.min.js")
@Html.GetJavascript("jquery.validate.unobtrusive.min.js")
@Html.GetCustomJavascript("resume.js")